package com.xyht.sca_s.student_manage_system.modules.employInfo.controller;


import com.xyht.sca_s.student_manage_system.auth.util.JwtTokenUtil;
import com.xyht.sca_s.student_manage_system.common.commonReturn.ResponseResult;
import com.xyht.sca_s.student_manage_system.common.desEncodeAndDecode.annotation.SecretBody;
import com.xyht.sca_s.student_manage_system.modules.employInfo.entity.req.SmsEmployInfoReq;
import com.xyht.sca_s.student_manage_system.modules.employInfo.service.SmsEmployInfoService;
import io.swagger.annotations.ApiModelProperty;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import javax.servlet.http.HttpServletRequest;

/**
 * <p>
 * 招聘信息表 前端控制器
 * </p>
 *
 * @author XYHT
 * @since 2023-09-11
 */
@RestController
@RequestMapping("/employ")
@SecretBody
public class SmsEmployInfoController {
    @Autowired
    private SmsEmployInfoService smsEmployInfoService;
    @Autowired
    private JwtTokenUtil jwtTokenUtil;

    @PostMapping("/add")
    @ApiModelProperty(value = "招聘信息添加")
    public ResponseResult addEmployInfo(@RequestBody SmsEmployInfoReq req, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmployInfoService.addEmployInfo(req,user_id);
    }

    @GetMapping("/webList")
    @ApiModelProperty(value = "招聘信息用户获取")
    public ResponseResult getEmployInfoWebList(@RequestParam("search_str") String search_str,
                                               @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                               @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize
                                               ){
        return smsEmployInfoService.getEmployInfoWebList(search_str, pageNum, pageSize);
    }

    @GetMapping("/backList")
    @ApiModelProperty(value = "招聘信息后台获取")
    public ResponseResult getEmployInfoBackList(@RequestParam("search_str") String search_str,
                                               @RequestParam(value = "pageNum",defaultValue = "1") Integer pageNum,
                                               @RequestParam(value = "pageSize",defaultValue = "10") Integer pageSize
                                               ){
        return smsEmployInfoService.getEmployInfoBackList(search_str, pageNum, pageSize);
    }

    @GetMapping("/detail")
    @ApiModelProperty(value = "招聘信息详情")
    public ResponseResult getEmployInfoDetail(@RequestParam("employ_id") String employ_id){
        return smsEmployInfoService.getEmployInfoDetail(employ_id);
    }

    @PostMapping("/update")
    @ApiModelProperty(value = "招聘信息修改")
    public ResponseResult updateEmployInfo(@RequestBody SmsEmployInfoReq req, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmployInfoService.updateEmployInfo(req,user_id);
    }

    @PostMapping("/delete")
    @ApiModelProperty(value = "招聘信息删除")
    public ResponseResult deleteEmployInfo(@RequestBody SmsEmployInfoReq req, HttpServletRequest request){
        String user_id = jwtTokenUtil.getUserIdByRequest(request);
        return smsEmployInfoService.deleteEmployInfo(req,user_id);
    }

}

